package com.borya.action;

import com.alibaba.fastjson.JSONObject;
import com.borya.framework.core.ServerRequest;
import com.borya.model.db.User;
import com.borya.model.entity.HeaderEntity;
import com.borya.model.entity.UserToken;

public abstract class BaseAction {

	protected JSONObject getJson(ServerRequest request) {
		if(request == null){
			return null;
		}
		
		return (JSONObject)request.getAttribute("json");
}
	
	protected User getUser(ServerRequest request) {
		if(request == null){
			return null;
		}
		return (User)request.getAttribute("user");
	}

    protected HeaderEntity getAuthHeader(ServerRequest request) {
        if (request == null) {
            return null;
        }
        return (HeaderEntity) request.getAttribute("boryaAuth");
    }

    protected UserToken getUserToken(ServerRequest request) {
        if (request == null) {
            return null;
        }
        return (UserToken) request.getAttribute("userToken");
    }


}